Conversation
This change removes variable-time padding behavior by writing into fixed-width buffers instead of slicing based on secret leading-zero counts. It also enforces the RFC 8017 ciphertext-length check before PKCS#1 v1.5 decryption and avoids variable-time Montgomery reduction on private-key paths. The patch adds regression tests covering padding edge cases, PKCS#1 v1.5 length rejection, and Montgomery reduction correctness.
tarcieri
reviewed
Sep 29, 2026
tarcieri
reviewed
Sep 29, 2026
Member
|
Overall I like the direction of this PR, thanks |
tarcieri
reviewed
Oct 1, 2026
| let (hi, lo) = bytes.split_at(bytes.len() - padded_len); | ||
| let overflow = hi.iter().fold(0u8, |acc, b| acc | b); | ||
| out.copy_from_slice(lo); | ||
| if core::hint::black_box(overflow) != 0 { |
Member
There was a problem hiding this comment.
This seems value-dependent? I'm also not sure what black_box is buying you here.
Author
There was a problem hiding this comment.
Yup agreed on both black_box was really just an optimizer hint anyway I'm gonna push soon to address this
8 tasks
Member
|
Note: I created #711 as a tracking issue for constant-time problems and noted this PR addresses several of them, or at least attempts to partially address them |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change removes variable-time padding behavior by writing into fixed-width buffers instead of slicing based on secret leading-zero counts. It also enforces the RFC 8017 ciphertext-length check before PKCS#1 v1.5 decryption and avoids variable-time Montgomery reduction on private-key paths. The patch adds regression tests covering padding edge cases, PKCS#1 v1.5 length rejection, and Montgomery reduction correctness.